<template>
    <el-dialog title="关键变更记录" :visible.sync="visible" :close-on-click-modal="false" append-to-body @close="cancel">

        <el-table style="width: 100%" :data="dataList" highlight-current-row>
            <el-table-column label="资产修订日期" align="center" prop="change_situation_tm" />
            <el-table-column label="存放地" align="center" show-overflow-tooltip prop="backup_fields4" />
            <el-table-column label="保管人" align="center" prop="backup_fields5">
                <template slot-scope="scope">
                    <dict-tag :options="dict.type.user_code" :value="scope.row.backup_fields5" />
                </template>
            </el-table-column>
            <el-table-column label="使用人" align="center" prop="backup_fields6">
                <template slot-scope="scope">
                    <dict-tag :options="dict.type.user_code" :value="scope.row.backup_fields6" />
                </template>
            </el-table-column>
            <el-table-column label="责任人" align="center" prop="backup_fields7">
                <template slot-scope="scope">
                    <dict-tag :options="dict.type.user_code" :value="scope.row.backup_fields7" />
                </template>
            </el-table-column>
            <el-table-column label="记录时间" align="center" prop="backup_fields8" />
            <el-table-column label="修订人" align="center" prop="backup_fields9" />
        </el-table>

    </el-dialog>
</template>

<script>
import { listByChange4SheBei } from "@/api/system/shebei";
import { listByChange4Jiaju } from "@/api/system/jiaju";
import { listByChange4Dinai } from "@/api/system/dinai";

export default {
    name: 'ChangeListDialog',
    props: {
        numberNo: { type: String, default: '' },
        type: { type: String, default: '' },
    },
    dicts: ['user_code'],

    data() {
        return {
            visible: false,
            dataList: [],
            // 查询参数
            queryParams: {
                instrumentNumber: '',
            },

        }
    },
    watch: {
        numberNo(newValue) {
            if (newValue) {
                //弹窗
                this.getList();
                this.visible = true
            } else {
                //关闭弹窗
                this.visible = false
            }
        }
    },
    methods: {
        // 取消按钮
        cancel() {
            this.close();
        },
        close() {
            this.$emit('update:numberNo', '');
        },
        getList() {
            this.queryParams.instrumentNumber = this.numberNo;
            if (this.type == '1') {
                listByChange4SheBei(this.queryParams).then(data => {
                    this.dataList = data;
                });
            } else if (this.type == '2') {
                listByChange4Dinai(this.queryParams).then(data => {
                    this.dataList = data;
                });
            } else if (this.type == '3') {
                listByChange4Jiaju(this.queryParams).then(data => {
                    this.dataList = data;
                });
            }

        },

    }
}
</script>
